package com.OnTimeTeam.OnTime;

import java.io.IOException;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;


public class MyLocation extends Activity {
	
	//private Button btnShowLocation;
	GPSManager gps;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		//setContentView(R.layout.activity_my_location);
		//btnShowLocation = (Button) findViewById(R.id.btnShowLocation);
		 
        // show location button click event
       // btnShowLocation.setOnClickListener(new View.OnClickListener() {
 
        //    public void onClick(View arg0) {
                // create class object
                gps = new GPSManager(this.getApplicationContext());
 
                // check if GPS enabled
                if(gps.canGetLocation()){
                	
                	//double latitude = gps.getLatitude();
                    //double longitude = gps.getLongitude();
                	String originAddress = "";
                	originAddress = gps.getLocationAddress();
                
                	Intent resultData = new Intent();
        			resultData.putExtra("valueName",originAddress);
        			setResult(Activity.RESULT_OK, resultData);
        			finish();
                	
                	//   Toast.makeText(getApplicationContext(), "Your Location is - \nLat: " + latitude + "\nLong: " + longitude + "\nThe address is:\n" + originAddress, Toast.LENGTH_LONG).show();
                }else{
                    // can't get location
                    // GPS or Network is not enabled
                    // Ask user to enable GPS/network in settings
                }
 
            }
     //   });
		 
		 
//	}
	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
	}

	@Override
	protected void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
	}

	@Override
	protected void onRestart() {
		// TODO Auto-generated method stub
		super.onRestart();
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_my_location, menu);
		return true;
	}

}
